/*
	Copyright (c) 2012 by karmaleaving@qq.com. All rights RESERVED.
*/

#include "config.h"
#ifndef __CONDE_H_VERSION_KL__
#define __CONDE_H_VERSION_KL__
KL_BEGIN
class Ascii
{
private:
	Ascii();
public:
	// use KL::not1(KL::ptr_fun(&...)) to make IsNotX().
	static bool IsSpace(char ch)
	{
		return (ch == SPC || ch == LF || ch == CR || ch == TAB);
	}
	static bool IsUpper(char ch)
	{
		return (ch >= A && ch <= Z);
	}
	static bool IsLower(char ch)
	{
		return (ch >= a && ch <= z);
	}
	static bool IsNum(char ch)
	{
		return (ch >= N0 && ch <= N9);
	}
	static bool IsAlpha(char ch)
	{
		return IsUpper(ch) || IsLower(ch);
	}
	static bool IsAlphaNum(char ch)
	{
		return IsAlpha(ch) || IsNum(ch);
	}
	static bool IsControl(char ch)
	{
		return !IsPrint(ch);
	}
	static bool IsX(char ch)
	{
		return IsNum(ch) || (ch >= a && ch <= f) || (ch >= A && ch <= F);
	}
	static bool IsText(char ch)
	{
		return (ch > SPC && ch < DEL) || IsSpace(ch);
	}
	static bool IsPrint(char ch)
	{
		return (ch >= SPC && ch < DEL);
	}
public:
	static char Upper(char ch)
	{
		return (IsLower(ch)) ? ch + (a - A) : ch;
	}
	static char Lower(char ch)
	{
		return (IsLower(ch)) ? ch - (a - A) : ch;
	}
public:
	static const char NUL = '\x00';  // NUL 
	static const char SOH = '\x01';  // start of header 
	static const char STX = '\x02';  // start of text 
	static const char ETX = '\x03';  // end of text 
	static const char EOT = '\x04';  // end of transmission 
	static const char ENQ = '\x05';  // enquiry 
	static const char ACK = '\x06';  // acknowledge 
	static const char BEL = '\x07';  // bell 
	static const char BS  = '\x08';  // backspace 
	static const char HT  = '\x09';  // horizontal tab 
	static const char TAB = '\x09';  // horizontal tab
	static const char LF  = '\x0A';  // line feed 
	static const char VT  = '\x0B';  // vertical tab 
	static const char FF  = '\x0C';  // form feed 
	static const char CR  = '\x0D';  // carriage return 
	static const char SO  = '\x0E';  // shift out 
	static const char SI  = '\x0F';  // shift in 
	static const char DLE = '\x10';  // data link escape 
	static const char DC1 = '\x11';  // no assignment, but usually XON 
	static const char DC2 = '\x12';  //  
	static const char DC3 = '\x13';  // no assignment, but usually XOFF 
	static const char DC4 = '\x14';  //  
	static const char NAK = '\x15';  // negative acknowledge 
	static const char SYN = '\x16';  // synchronous idle 
	static const char ETB = '\x17';  // end of transmission block 
	static const char CAN = '\x18';  // cancel 
	static const char EM  = '\x19';  // end of medium 
	static const char SUB = '\x1A';  // substitute 
	static const char ESC = '\x1B';  // escape 
	static const char FS  = '\x1C';  // file seperator 
	static const char GS  = '\x1D';  // group seperator 
	static const char RS  = '\x1E';  // record seperator 
	static const char US  = '\x1F';  // unit seperator 
	static const char SPC = '\x20';  // space 

	static const char Bang     = '\x21';  // !  excalmatory mark
	static const char DQM      = '\x22';  // "  double quote mark
	static const char She      = '\x23';  // #  pound
	static const char Dollar   = '\x24';  // $  
	static const char Percent  = '\x25';  // %  
	static const char And      = '\x26';  // &  ampersand
	static const char SQM      = '\x27';  // '  single quote mark
	static const char LParen   = '\x28';  // (  parenthesis
	static const char RParen   = '\x29';  // )  parenthesis
	static const char Star     = '\x2A';  // *  
	static const char Plus     = '\x2B';  // +  
	static const char Comma    = '\x2C';  // ,  
	static const char Minus    = '\x2D';  // -  
	static const char Dot      = '\x2E';  // .  
	static const char Slash    = '\x2F';  // /  
	static const char N0 = '\x30';  // 0  
	static const char N1 = '\x31';  // 1  
	static const char N2 = '\x32';  // 2  
	static const char N3 = '\x33';  // 3  
	static const char N4 = '\x34';  // 4  
	static const char N5 = '\x35';  // 5  
	static const char N6 = '\x36';  // 6  
	static const char N7 = '\x37';  // 7  
	static const char N8 = '\x38';  // 8  
	static const char N9 = '\x39';  // 9  
	static const char Colon     = '\x3A';  // :  
	static const char Semicolon = '\x3B';  // ;  
	static const char LT        = '\x3C';  // <  
	static const char Equal     = '\x3D';  // =  
	static const char GT        = '\x3E';  // >  
	static const char QM        = '\x3F';  // ?  
	static const char At        = '\x40';  // @  
	static const char A   = '\x41';  // A  
	static const char B   = '\x42';  // B  
	static const char C   = '\x43';  // C  
	static const char D   = '\x44';  // D  
	static const char E   = '\x45';  // E  
	static const char F   = '\x46';  // F  
	static const char G   = '\x47';  // G  
	static const char H   = '\x48';  // H  
	static const char I   = '\x49';  // I  
	static const char J   = '\x4A';  // J  
	static const char K   = '\x4B';  // K  
	static const char L   = '\x4C';  // L  
	static const char M   = '\x4D';  // M  
	static const char N   = '\x4E';  // N  
	static const char O   = '\x4F';  // O  
	static const char P   = '\x50';  // P 
	static const char Q   = '\x51';  // Q  
	static const char R   = '\x52';  // R  
	static const char S   = '\x53';  // S  
	static const char T   = '\x54';  // T  
	static const char U   = '\x55';  // U  
	static const char V   = '\x56';  // V  
	static const char W   = '\x57';  // W  
	static const char X   = '\x58';  // X  
	static const char Y   = '\x59';  // Y  
	static const char Z   = '\x5A';  // Z  
	static const char LBracket = '\x5B';  // [  Open Bracket
	static const char BSlash   = '\x5C';  // \  back slash
	static const char RBracket = '\x5D';  // ]  Close Bracket
	static const char Caret    = '\x5E';  // ^  caret
	static const char HB       = '\x5F';  // _  underscore
	static const char BQuote   = '\x60';  // `  back quote mark
	static const char a   = '\x61';  // a  
	static const char b   = '\x62';  // b  
	static const char c   = '\x63';  // c  
	static const char d   = '\x64';  // d  
	static const char e   = '\x65';  // e  
	static const char f   = '\x66';  // f  
	static const char g   = '\x67';  // g  
	static const char h   = '\x68';  // h  
	static const char i   = '\x69';  // i  
	static const char j   = '\x6A';  // j  
	static const char k   = '\x6B';  // k  
	static const char l   = '\x6C';  // l  
	static const char m   = '\x6D';  // m  
	static const char n   = '\x6E';  // n  
	static const char o   = '\x6F';  // o  
	static const char p   = '\x70';  // p  
	static const char q   = '\x71';  // q  
	static const char r   = '\x72';  // r  
	static const char s   = '\x73';  // s  
	static const char t   = '\x74';  // t  
	static const char u   = '\x75';  // u  
	static const char v   = '\x76';  // v  
	static const char w   = '\x77';  // w  
	static const char x   = '\x78';  // x  
	static const char y   = '\x79';  // y  
	static const char z   = '\x7A';  // z  
	static const char LBrace = '\x7B';  // {  open brace
	static const char VB     = '\x7C';  // |  virtical bar
	static const char RBrace = '\x7D';  // }  
	static const char Tilde  = '\x7E';  // ~  
	static const char DEL    = '\x7F';  // DEL delete 
};
KL_END
#endif // __CONDE_H_VERSION_KL__
